import React from "react";
import {isWin,getNowStep,full} from "./utils"

const mapping = {
    0:' ',
    1:'X',
    2:'O'
}

class Display extends React.Component{
    constructor(props) {
        super(props);
        // this.props.nowMap;
    }
    render() {
        let text = ''
        if (isWin(this.props.nowMap)){
            text = "Winner: " + mapping[getNowStep(this.props.nowMap)];
        }else if (full(this.props.nowMap)){
            text = "Draw!"
        }else{
            text = "Next: " + (getNowStep(this.props.nowMap) === 1 ? 'O': 'X');
        }
        return (
            <div>
                {text}
            </div>
        )
    }
}

export default Display;
